<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <title>门店信息</title>
    <link rel="stylesheet" href="../../styles/h5/reset.min.css"/>
    <link rel="stylesheet" href="../../styles/h5/errortankuang.css"/>
    <!--以上为公共css样式-->
    <link rel="stylesheet" href="../../styles/h5/index.css"/>

    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery-1.9.1.min.js"></script>
    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery.modal.js"></script>
    <!--以上为公共js文件-->
</head>
<body>
<div class="zz-top"></div>
<div class="zz-list zz-default-store">
    <ul>
        <!--<li>
            <a href="javascript:;">
                <span class="zz-left">默认店铺</span>
                <span class="zz-right-arrow"></span>
                <span class="zz-replace">丰源包子铺-小西天</span>
            </a>
        </li>
        <li>
            <a href="javascript:;">
                <span class="zz-left">商户号</span>
                <span class="zz-replace zz-merchant-num">123456789</span>
            </a>
        </li>
        <li>
            <a href="javascript:;">
                <span class="zz-left">收款二维码</span>
                <span class="zz-right-arrow"></span>
            </a>
        </li>-->
    </ul>
</div>
<div class="zz-top"></div>
<div class="zz-list">
    <ul>
        <li>
            <a class="zz-productStore" href="javascript:;">
                <span class="zz-left">产品商店</span>
                <span class="zz-right-arrow"></span>
            </a>
        </li>
    </ul>
</div>
<input class="zz-close zz-position-4" type="button" value="注销登录">
</body>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/utils.js"></script>
<script charset="utf-8" type="text/javascript">
	var data = '';

    function bindHTML() {
        var str = '';
        if (data.length > 1) {
            var index = "";
            for (var i = 0; i < data.length; i++) {
                var curData = data[i];
                if (curData["defultStore"] == 0) {
                    index = i;
                    break;
                } else {
                	index = 0;
                }
            }
            str += '<li>';
            str += '<a href="../../html/h5/gatheringChoiceStore.html?merId=' + data[index]['merId'] + '">';
            str += '<span class="zz-left">默认店铺</span>';
            str += '<span class="zz-right-arrow"></span>';
            str += '<span class="zz-replace zz-storeId" merId="' + data[index]["merId"] + '" storeId="' + data[index]["storeId"] + '">' + data[index]["storeShortName"] + '</span>';
            str += '</a>';
            str += '</li>';
            str += '<li>';
            str += '<a href="javascript:;">';
            str += '<span class="zz-left">商户号</span>';
            str += '<span class="zz-replace zz-merchant-num">' + data[index]["storeId"] + '</span>';
            str += '</a>';
            str += '</li>';
            str += '<li>';
            str += '<a href="../../html/h5/gatheringEwm.html?storeId=' + data[index]['storeId'] + '">';
            str += '<span class="zz-left">收款二维码</span>';
            str += '<span class="zz-right-arrow"></span>';
            str += '</a>';
            str += '</li>';
        } else {
            str += '<li>';
            str += '<a href="javascript:;">';
            str += '<span class="zz-left">默认店铺</span>';
            str += '<span class="zz-right-arrow"></span>';
            str += '<span class="zz-replace zz-storeId" merId="' + data[0]["merId"] + '" storeId="' + data[0]["storeId"] + '">' + data[0]["storeShortName"] + '</span>';
            str += '</a>';
            str += '</li>';
            str += '<li>';
            str += '<a href="javascript:;">';
            str += '<span class="zz-left">商户号</span>';
            str += '<span class="zz-replace zz-merchant-num">' + data[0]["storeId"] + '</span>';
            str += '</a>';
            str += '</li>';
            str += '<li>';
            str += '<a href="../../html/h5/gatheringEwm.html?storeId=' + data[0]['storeId'] + '">';
            str += '<span class="zz-left">收款二维码</span>';
            str += '<span class="zz-right-arrow"></span>';
            str += '</a>';
            str += '</li>';
        }
        $(".zz-default-store ul").html(str);
    }
   
    $.ajax({
        url: utils.ajaxUrl()+"h5/store/receiver/getStoreByOpenid",
        data: {},
        async: false,
        type: 'get',
        success: function (res) {
        	var res = JSON.parse(res);
        	//console.log(res);
            if (res && res.retCode == '0000') {
                data = res["storeList"];
                //console.log(data);
                bindHTML();
                var $storeId = $(".zz-storeId");
                var storeId = $storeId.attr("storeId");
                var merId = $storeId.attr("merId");
				//console.log(storeId)
				//console.log(merId)
                $(".zz-productStore").attr("href", "../../html/h5/productStore.html?storeId=" + storeId + "&merId=" + merId);
            } else {
                new $.modal({
                    content: res.retMsg,//弹框内容
                    showcontent: true,//false为弹出框组件二，true为弹出框组件一
                }).show();
            }
        }
    });

</script>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/index.js"></script>
<script charset="utf-8" type="text/javascript">
	$(".zz-close").click(function (){
        new $.modal({
            title: '提示',//弹框title
            content: '确定退出登录？',//弹框内容
            isshowclosebtn: true,//是否显示取消按钮
            showcontent: false,//false为弹出框组件二，true为弹出框组件一
            closecallback: function () {
            },//点击关闭时触发事件
            surecallback: function () {
                //点击确定时触发事件
                $.ajax({
                    url: utils.ajaxUrl()+"h5/store/receiver/logout",
                    async: false,
                    type: 'get',
                    success: function (re) {
                    	var re = JSON.parse(re);
                    	//alert(re.retCode);
                        if (re && re.retCode == '0000') {
                            WeixinJSBridge.call('closeWindow');
                        } else {
                            new $.modal({
                                content: re.retMsg,//弹框内容
                                showcontent: true,//false为弹出框组件二，true为弹出框组件一
                            }).show($(".zz-close"));
                        }
                    }
                });
            }
        }).show();
    })
</script>
</html>